package com.zj.core.net

import java.util.HashMap

import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import okhttp3.ResponseBody

/**
 * 日期：2019年3月22日
 * 公司：北京子杰宝贝科技有限公司
 * 地址：北京市朝阳区朝阳农场
 * 开发者：达选文
 *
 * 主体功能：网络数据请求层
 */
class NetWorkModel{

    var ytzyFormService: RetrofitService? = null

    init {
        ytzyFormService = RetrofitClient().getInstance()?.create(RetrofitService::class.java)
    }

    /**
     * 1.4.1
     */
    fun rxjava_getNurseOperationRecord(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getNurseOperationRecord(map), mSubscriber)
    }

    /**
     * 1.4.3
     */
    fun rxjava_addRemarkForOperation(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.addRemarkForOperation(map), mSubscriber)
    }

    /**
     * 1.4.12
     */
    fun rxjava_getVoiceTemplate(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getVoiceTemplate(map), mSubscriber)
    }

    /**
     * 1.4.16
     */
    fun rxjava_getConfigMes(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getConfigMessage(map), mSubscriber)
    }

    /**
     * 1.4.20
     */
    fun rxjava_getTemplateTitle(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getTemplateTitle(map), mSubscriber)
    }

    /**
     * 1.4.25
     */
    fun rxjava_queryNurseInfo(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.queryNurseInfo(map), mSubscriber)
    }

    /**
     * 1.4.26
     */
    fun rxjava_bindNurseName(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.bindNurseName(map), mSubscriber)
    }

    /**
     * 1.4.29
     */
    fun rxjava_getVideoMessage(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getVideoMessage(map), mSubscriber)
    }

    /**
     * 1.4.30
     */
    fun rxjava_getDrugsList(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getDrugsList(map), mSubscriber)
    }

    /**
     * 1.4.31
     */
    fun rxjava_updateVersion(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.updateVersion(map), mSubscriber)
    }

    /**
     * 1.4.32
     */
    fun rxjava_getFormList(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getFormList(map), mSubscriber)
    }

    /**
     * 1.4.33
     */
    fun rxjava_getNurseLevel(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getNurseLevel(map), mSubscriber)
    }

    /**
     * 1.4.34
     */
    fun rxjava_postVoiceHistory(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.postVoiceHistory(map), mSubscriber)
    }

    /**
     * 1.4.35
     */
    fun rxjava_getFormKey(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getFormKey(map), mSubscriber)
    }

    /**
     * 1.4.36
     */
    fun rxjava_getHospitalStatusKey(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
        execute(ytzyFormService?.getHospitalStatusKey(map), mSubscriber)
    }



//    /**
//     * 获取详细的操作记录
//     * @param mSubscriber
//     * @param patientId
//     * @param mPageNum
//     */
//    fun rxjava_getDetailOperationRecord(mSubscriber: Observer<ResponseBody>, patientId: String, mPageNum: Int) {
//        execute(ytzyFormService?.getDetailOperationRecord(patientId, mPageNum), mSubscriber)
//    }

//    /**
//     * 新增患者备注
//     * @param mSubscriber
//     * @param map
//     */
//    fun rxjava_patientRemark(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
//        execute(ytzyFormService?.patientRemark(map), mSubscriber)
//    }

//    /**
//     * 新增患者备注
//     * @param mSubscriber
//     * @param map
//     */
//    fun rxjava_getPatientRemark(mSubscriber: Observer<ResponseBody>, map: HashMap<String, String>) {
//        execute(ytzyFormService?.getPatientRemark(map), mSubscriber)
//    }



    fun execute(reponse_observable: Observable<ResponseBody>?, mSubscriber: Observer<ResponseBody>) {
        reponse_observable?.subscribeOn(Schedulers.io())
            ?.observeOn(AndroidSchedulers.mainThread())
            ?.subscribe(mSubscriber)
    }
}
